//
//  StarWorkCollectionViewCell.m
//  WULIHH
//
//  Created by tang on 16/4/26.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "StarWorkCollectionViewCell.h"
//#import "UIImageView+AFNetworking.h"
#import "UIImageView+WebCache.h"

@interface StarWorkCollectionViewCell ()
{
    UIImageView *headImageView;
    UILabel *userTitleLable;
    UILabel *titleLable;
    UIImageView *backImageView;
}

@end


@implementation StarWorkCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initUI];
    }
    return self;
}



- (void)initUI
{
    UIView *backView = [[UIView alloc] initWithFrame:self.bounds];
    [self addSubview:backView];
    [backView.layer setCornerRadius:9.0];
    [backView setBackgroundColor:[UIColor whiteColor]];
    [backView setOpaque:NO];
    
    headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(6, 10, 24, 24)];
    [headImageView setOpaque:NO];
    [self addSubview:headImageView];
    
    userTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(headImageView.frame)+8, 15.0, self.bounds.size.width-CGRectGetMaxX(headImageView.frame)-8, 25.0)];
    [userTitleLable setTextAlignment:NSTextAlignmentLeft];
    [userTitleLable setFont:[UIFont systemFontOfSize:12.0]];
    [self addSubview:userTitleLable];
    
    backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 42.0, self.bounds.size.width, self.bounds.size.height-85.0)];
    [self addSubview:backImageView];
    [backImageView setOpaque:NO];
    
    titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height-43.0, self.bounds.size.width, 43.0)];
    [titleLable setNumberOfLines:2.0];
    [self addSubview:titleLable];
}




- (void)loadModel:(NSDictionary *)dic
{
    [userTitleLable setText:[[dic valueForKey:@"user"] valueForKey:@"username"]];
    [headImageView sd_setImageWithURL:[NSURL URLWithString:[[dic valueForKey:@"user"] valueForKey:@"iconUrl"]]];
    [backImageView sd_setImageWithURL:[NSURL URLWithString:[[dic valueForKey:@"image"] valueForKey:@"imageUrl"]]];
    [titleLable setText:[dic valueForKey:@"title"]];
}




@end
